﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WpfControlLibrary
{
    /// <summary>
    /// Interaction logic for ListPage.xaml
    /// </summary>
    public partial class ListPage : UserControl
    {

        private MaterialList materialList;
        public ListPage()
        {
            InitializeComponent();
            materialList = new MaterialList();
            materialList.Add(new MaterialItem("1", "第一个素材", "ppt_pptx", false, "A001", "Internal_disclosure", "内部公开", 100));
            materialList.Add(new MaterialItem("2", "第二个素材", "docx_doc", true, "A001", "External_disclosure", "外部公开", 200));
            materialList.Add(new MaterialItem("3", "第三个素材", "xlsx", true, "A001", "Secret_and_above", "秘密及以上", 200));
            materialList.Add(new MaterialItem("4", "第三个素材", "jpg_png_gif", false, "A002", "confidential", "机密", 200));
            materialList.Add(new MaterialItem("4", "第三个素材", "txt", true, "A004", "Internal_disclosure", "内部公开", 200));
            materialList.Add(new MaterialItem("5", "第三个素材", "mp3", false, "A005", "Internal_disclosure", "内部公开", 200));
            materialList.Add(new MaterialItem("6", "第三个素材", "pdf", false, "A006", "Internal_disclosure", "内部公开", 200));
            Binding binding = new Binding();
            binding.Source = materialList;
            itemList.SetBinding(ListBox.ItemsSourceProperty, binding);
        }

        private void add_Click(object sender, RoutedEventArgs e)
        {

            Button btn = sender as Button;
            MaterialItem item = btn.Tag as MaterialItem;
            if (item != null)
            {
                MessageBox.Show(item.ToString());
            }
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {

        }

        private void type_Click(object sender, RoutedEventArgs e)
        {

        }

        private void fileFormat_Click(object sender, RoutedEventArgs e)
        {
            MessageBox.Show(itemList.Items.GetItemAt(0).GetType().ToString());


        }

        private void language_Click(object sender, RoutedEventArgs e)
        {

        }

        private void salesCategory_Click(object sender, RoutedEventArgs e)
        {
            materialList.Add(new MaterialItem("6", "第三个素材", "pdf", false, "A006", "Internal_disclosure", "内部公开", 200));

        }

        private void order_Click(object sender, RoutedEventArgs e)
        {

            MessageBox.Show("按时间排序");
        }
    }
}
